ResizeBank
ResizeBank BankIndex, NewSize
 
Parameters:

    BankIndex = The Index Identifier of the bank that you wish to create.
    NewSize = The new size in bytes of this memory bank
Returns: NONE
 

      The ResizeBank command lets us change the size of a previously created memory bank. The resize process preserves the existing contents of the bank, providing the bank is expanded. If you shrink the bank, then any excess data, which is data beyond the new size, will of course be lost.



FACTS:


     * When resizing a bank the location of the bank in memory will most likely be altered. So if you need a raw pointer to the memory inside the bank, then it's best to refresh your pointer to the bank (GetBankPtr) after a resize. Otherwise you risk pointing at a section of memory your program no longer owns, which will most likely crash your application.






Mini Tutorial:


     In this example, we create a bank and fills the bank full of bytes. once we've done that we've something to resize in order to show what ResizeBank does. So the program first resizes the bank down to 10 bytes and displays the contents, then rpeats the process but this time resizing it to 20 bytes.


  
; Create Memory Bank #1 and make it 100 bytes in size
  CreateBank 1,100
  
; Fill Bank with some with bytes
  For lp=0 To GetBankSize(1)-1
     PokeBankByte 1,lp, lp
  Next
  
; Display the status of this bank
  Print "Bank Satus:"+Str$(GetBankStatus(1))
  Print " Bank Size:"+Str$(GetBankSize(1))
  Print ""
  
; Resize the bank back to 10 bytes
  ResizeBank 1,10
  
; Display the status of this bank
  Print " Bank Size After Resize:"+Str$(GetBankSize(1))
  
; SHow the bank after it's been resized up
  SHowBankContents(1)
  
; Resize the bank back to 20 bytes
  ResizeBank 1,20
  
; Display the status of this bank
  Print " Bank Size After Resize:"+Str$(GetBankSize(1))
  
; SHow the bank after it's been resized up
  SHowBankContents(1)
  
; Display the Screen and wait for the user to press a key
  Sync
  WaitKey
  
  
  
  
Function SHowBankContents(ThisBank)
  
  s$=""
  For lp=0 To GetBankSize(ThisBank)-1
     s$+=Str$(PeekBankByte(ThisBank,lp))+","
  Next
  Print "  Resized Bank Contents:"+Trim$(s$,",")
  Print ""
  
EndFunction
  
  




This example would output.

  
  Bank Satus:1
  Bank Size:100
  
  Bank Size After Resize:10
  Resized Bank Contents:0,1,2,3,4,5,6,7,8,9
  
  Bank Size After Resize:20
  Resized Bank Contents:0,1,2,3,4,5,6,7,8,9,0,0,0,0,0,0,0,0,0,0
  
  

 
Related Info: CreateBank | DeleteBank | GetBankSize | NewBank | PeekBankByte | PeekBankFloat | PeekBankInt | PeekBankString | PeekBankWord | POinter | PokeBankByte | PokeBankFloat | PokeBankInt | PokeBankString :
 


(c) Copyright 2002 - 2024 - Kevin Picone - PlayBASIC.com